package entities
{
	import parsers.MicroOBJParser;

	import flash.display.Bitmap;
	import flash.display3D.Context3D;
	import flash.display3D.Context3DTextureFormat;
	import flash.display3D.Program3D;
	import flash.display3D.textures.Texture;
	import flash.geom.Matrix3D;
	/**
	 * @author perry
	 */
	public class MicroGZMCar extends MicroGZMEntity
	{
		[Embed (source = "textures/car.jpg")]
		private var playerTextureBitmap:Class;
		private var playerTextureData:Bitmap = new playerTextureBitmap();
		
		private var carTexture:Texture;
		
		[Embed (source = "models/chevy.obj", mimeType = "application/octet-stream")]
		private var modelData:Class;
		
//		private var aceleration:Number;
		
		public function MicroGZMCar( contextIn:Context3D = null, shaderIn:Program3D = null,
									 textureIn:Texture = null, modelscale:Number = 1,
									 flipAxis:Boolean = true, flipTexture: Boolean = true )
		{
			
			transform = new Matrix3D();
			context = contextIn;
			shader = shaderIn;
			texture = carTexture;
			
			if( !textureIn )
			{
				carTexture = context.createTexture( playerTextureData.width, playerTextureData.height, Context3DTextureFormat.BGRA, false);
				uploadTextureWithMipmaps( carTexture, playerTextureData.bitmapData );
			}
			else
			{
				carTexture = textureIn;
			}
			
			
			if (modelData && context)
			{
				mesh = new MicroOBJParser( modelData, context, modelscale, flipAxis, flipTexture );
				polycount = mesh.indexBufferCount;
				width = mesh.width;
				height = mesh.height;
				depth = mesh.depth;
			}
			
			texture = carTexture;
		}

	}
}
